/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client.modele;

import Exceptions.InputAnnuiteException;
import Exceptions.InputChoixException;
import Exceptions.InputMontantException;
import Exceptions.InputNbAnException;
import Exceptions.InputTxInteretException;
import Serveur.RemoteResources;
import exception.CommunicationResponseApplicationException;
import exception.ReadingObjectException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Florian
 */
public class ModeleRMI implements InterfaceModele {

    private RemoteResources obj;

    public ModeleRMI() {
    }

    @Override
    public double envoyerDemandeAnnuites(double montant, double txInterets, int nbAnnuite) throws CommunicationResponseApplicationException, InputAnnuiteException, InputChoixException, InputTxInteretException, InputMontantException, InputMontantException, InputNbAnException, ReadingObjectException {
        try {
            obj = (RemoteResources) Naming.lookup("/CalculServices");
            return obj.calculAnnuite(montant, txInterets, nbAnnuite);
        } catch (RemoteException ex) {
            throw new CommunicationResponseApplicationException();
        } catch (NotBoundException ex) {
            throw new CommunicationResponseApplicationException();
        } catch (MalformedURLException ex) {
            throw new CommunicationResponseApplicationException();
        }
    }

    @Override
    public double envoyerDemandeNbAnnees(double montant, double txInterets, double annuite) throws CommunicationResponseApplicationException, InputAnnuiteException, InputChoixException, InputTxInteretException, InputMontantException, InputMontantException, InputNbAnException, ReadingObjectException {
        try {
            obj = (RemoteResources) Naming.lookup("/CalculServices");
            return obj.calculNbAnnees(montant, txInterets, annuite);
        } catch (RemoteException ex) {
            throw new CommunicationResponseApplicationException();
        } catch (NotBoundException ex) {
            throw new CommunicationResponseApplicationException();
        } catch (MalformedURLException ex) {
            throw new CommunicationResponseApplicationException();
        }
    }
}
